from django.db import models


# Create your models here.


class CateModel(models.Model):
    name = models.CharField(max_length=30)

    class Meta:
        db_table = 'cate'

    def __str__(self):
        return self.name


class GoodsModel(models.Model):
    name = models.CharField(max_length=30)
    price = models.DecimalField(max_digits=8, decimal_places=2)
    img = models.ImageField(upload_to='static/img')
    grade = models.IntegerField(default=0, verbose_name='评分')
    cate = models.ForeignKey(CateModel, on_delete=models.CASCADE)

    class Meta:
        db_table = 'goods'

    def __str__(self):
        return self.name


class OrderModel(models.Model):
    name = models.CharField(max_length=30)
    count = models.IntegerField(default=0)
    s_name = models.CharField(max_length=30, verbose_name='收货人姓名')
    site = models.CharField(max_length=200, verbose_name='地址')
    phone = models.CharField(max_length=11)
    content = models.CharField(max_length=200, verbose_name='备注')
    status = models.BooleanField(default=0, verbose_name='订单状态')

    class Meta:
        db_table = 'order'

    def __str__(self):
        return self.name
